var a = require("../../../@babel/runtime/helpers/interopRequireDefault"), t = a(require("../DPagination")), e = a(require("../DHttp")), i = new t.default("detailData");

Page({
    data: {
        currentShowTab: "all",
        detailData: {},
        detailPageCount: 0
    },
    onLoad: function(a) {
        i.bind(this), i.clean(), this.loadDetailData("all");
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.loadDetailData(this.data.currentShowTab);
    },
    onShareAppMessage: function() {},
    switchListTab: function(a) {
        var t = a.detail.name;
        i.clean(), this.loadDetailData(t), this.setData({
            detailPageCount: 0
        });
    },
    loadDetailData: function(a) {
        switch (a) {
          case "all":
            this.getDetailData(null);
            break;

          case "income":
            this.getDetailData(1);
            break;

          case "expenditure":
            this.getDetailData(2);
        }
    },
    getDetailData: function(a) {
        var t = this;
        if (!i.loading && !i.finished) {
            i.loading = !0, wx.showLoading({
                title: "加载中",
                mask: !0
            });
            var n = {
                page: i.loadPage
            };
            null !== n && (n.detail_type = a), e.default.request("plugin.credit-inventory.frontend.controllers.detail.index", n).then(function(a) {
                var e = a.data, n = a.last_page, o = a.current_page, l = a.per_page;
                i.loading = !1, wx.hideLoading(), (n == o || e.length < l) && (i.finished = !0), 
                i.limit = l, i.push(e), t.setData({
                    detailPageCount: t.data.detailPageCount + e.length
                });
            }).catch(function(a) {
                var t = a.msg;
                wx.hideLoading(), wx.showToast({
                    title: t,
                    icon: "none"
                }), i.loading = !1;
            });
        }
    }
});